﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ks.Fs.Entity;
using System.Data;

namespace Ks.Fs.Core.Data.SqlDataProvider.Mapper
{
    public class FileMapper : GenericMapper<File>
    {
        protected override File MapOne(IDataRecord record)
        {
            File obj = new File();

            if (record["Id"] != DBNull.Value)
            {
                obj.Id = Convert.ToInt32(record["Id"]);
            }

            if (record["Name"] != DBNull.Value)
            {
                obj.Filename = Convert.ToString(record["Name"]);
            }

            if (record["FolderId"] != DBNull.Value)
            {
                obj.FolderId = Convert.ToInt32(record["FolderId"]);
            }

            if (record["Size"] != DBNull.Value)
            {
                obj.Size = Convert.ToInt32(record["Size"]);
            }

            if (record["LastModified"] != DBNull.Value)
            {
                obj.LastModified = Convert.ToDateTime(record["LastModified"]);
            } 

            if (record["Owner"] != DBNull.Value)
            {
                obj.Owner = Convert.ToString(record["Owner"]);
            }
           
            if (record["Path"] != DBNull.Value)
            {
                obj.Path = Convert.ToString(record["Path"]);
            }
               
            return obj;
        }
    }
}
